#include "mythSQLresult.hh"
#include <string.h>

mythSQLresult::mythSQLresult(void)
{
	this->result = NULL;
	this->row = 0;
	this->colum = 0;
	current = 0;
}


mythSQLresult::~mythSQLresult(void)
{
}

mythSQLresult* mythSQLresult::CreateNew()
{
	return new mythSQLresult();
}

int mythSQLresult::close()
{	
	sqlite3_free_table(result);
	return 0;
}

char* mythSQLresult::prase(char* keywords )
{
	if(current == 0)return NULL;
	if(keywords == NULL){
		return NULL;
	}else{
		for(int i = 0;i< colum;i++){
			char* tmp = *(result + i);
			if(strcmp(keywords,tmp) == 0){
				return *(result + colum * current + i);
			}
		}
	}
	return NULL;
}

bool mythSQLresult::MoveNext()
{
	if(current == row)return false;
	current++;return true;
}

void mythSQLresult::myth_toupper( char** data )
{
	for(int i = 0;;i++){
		if(*data[i] == 0)break;
		 if(*data[i]<='z'&& *data[i]>='a'){
			 *data[i] += 32;
		 }
	}
}
